package com.test.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.test.domain.TAccountuser;
import com.test.domain.User;
import com.test.mapper.InformMapper;
import com.test.mapper.UserMapper;
import com.test.service.InformService;
import com.test.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.entity.Example;

import javax.swing.text.TabableView;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.*;

@Service
public class InformServiceImpl extends BaseServiceImpl<TAccountuser> implements InformService {

	@Autowired
	private InformMapper informMapper;

	@Override
	protected Mapper<TAccountuser> getMapper() {
		return this.informMapper;
	}

	@Override
	public PageInfo<TAccountuser> getInformListByPage(int currentNum, int pageSize, String name) {
		Example cond = new Example(TAccountuser.class);
		if (!StringUtils.isEmpty(name)) {
			try {
				name = new String(name.getBytes("utf-8"),"utf-8");
			} catch (UnsupportedEncodingException e) {
				e.printStackTrace();
			}
			cond.createCriteria().andLike("realname","%" + name + "%");
		}
		PageHelper.startPage(currentNum, pageSize);
		List<TAccountuser> list = this.informMapper.selectByExample(cond);
		return new PageInfo<TAccountuser>(list);
	}

	@Override
	public   void setAdvice(TAccountuser accountuser){
		informMapper.setAdvice(accountuser);
	}
	}

